<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="expires" CONTENT="0">
    <link rel="shortcut icon" href="../../static/favicon.ico">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <link rel="stylesheet" href="../../static/personal_center/sign_in/c/css/bootstrap.css">
    <link rel="stylesheet" href="../../static/personal_center/sign_in/c/login/login1.css">
    <script src="../../static/personal_center/sign_in/j/js/jquery.js"></script>
    <script src="../../static/personal_center/sign_in/j/js/bootstrap.js"></script>
    <script src="../../static/personal_center/js/coco-message.js"></script>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>京山市人民医院-OA系统</title>
    <script type="text/javascript">
        {#if (window.history && window.history.pushState) {#}
        {#    window.history.pushState('forward', null, './#forward');#}
        {#    window.history.forward();#}
        {# }#}
    </script>
    <style>
        html {
            background-image: url('../../static/public_file/images/111.jpeg');
            background-repeat: no-repeat;
            background-size: 100% 100%;
            width: 100%;
            height: 100%;
        }

        .inputStyle {
            vertical-align: text-bottom;
            margin-bottom: 2px;
            *margin-bottom: -2px;
        / / 兼容IE6，IE7
        }

        #test {
            margin: 0 auto;
            width: 1000px;
            height: calc(160vh - 100px);
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #test button {
            margin: 0 20px;
        }

        .coco-btn {
            font-size: 14px;
            text-decoration: none;
            padding: 6px 20px;
            white-space: nowrap;
            border-radius: 3px;
            font-weight: 500;
            display: inline-block;
            cursor: pointer;
            border: 0;
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            line-height: normal;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        .coco-btn.cancel {
            margin-right: 10px;
            color: #525456;
            background-color: transparent;
            font-weight: 500;
            transition: all 0.06s ease-out;
        }

        .coco-btn,
        .coco-btn span,
        .coco-loading {
            position: relative;
        }

        .coco-btn.ok {
            background-color: #0077ff;
            color: #fefefe;
        }

        .coco-btn.ok::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: inherit;
            transition: all 0.12s ease-out;
            background-color: transparent;
        }

        .coco-btn.ok:hover::before {
            background-color: rgba(255, 255, 255, 0.08);
        }

        .coco-btn.ok:active::before {
            transition: all 80ms ease-out;
            background-color: rgba(0, 0, 0, 0.2);
        }
    </style>
</head>
<body>

<div style="margin-top: 10%;">
    <div class="be-content pren">

        <div class="ioc_text">
            <img style="width: 70%;height: 50px;" src="../../static/public_file/images/logo2的副本.png" alt="">
{#            <img style="width: 70%;height: 50px;" src="../../static/personal_center/img/行政管理系统 - 副本.png" alt="">#}
        </div>

        <div>
{#            <form>#}
            <div class="br-content">
                <div id="remind_div" style="width: 100%;height: 30px;border: #b81900 solid 1px;visibility: hidden;">
                    <img src="../../static/finance/img/提示说明.png" style="width: 12px;height: 12px;margin-left: 2%;" alt="">
                    <span id="remind_text" style="font-size: 12px;color: #b81900;">请输入用户名</span>
                </div>

                <div class="input-group mb-4 bootint">
                    <div class="input-group-prepend">
                        <span class="input-group-text"><img src="../../static/personal_center/img/用户名.png" style="height: 15px;width: 15px;" alt=""></span>
                    </div>
                    <input type="text" class="form-control" placeholder="用户名" name="username" id="username" value="{{ username }}">
                </div>

                <div class="input-group mb-4 bootint">
                    <div class="input-group-prepend">
                        <span class="input-group-text"><img src="../../static/personal_center/img/密码.png" style="height: 15px;width: 15px;" alt=""></span>
                    </div>
                    <input type="password" class="form-control" placeholder="密码" name="pwd" id="pwd" value="{{ pwd }}">
                </div>

                <div class="br-text">
                    <p>
                    <div class="custom-control custom-checkbox d-inline-block mt-2 pt-1"
                         style="height: 20px;line-height: 20px;">
                        <input style="vertical-align: middle;" type="checkbox" class="custom-control-input"
                               id="remembered" name="remembered">
                        <label class="custom-control-label" for="remembered" style="color: white">记住我</label>
                    </div>
                    </p>

                </div>

                <div style="padding-top: 10px">
                    <button id="submmit_but" class="btn" value="登录" onclick="signin_but()">登录</button>
                </div>
            </div>
            <div class="be-con" style="width: 100%;text-align: right;font-size: 16px;padding-right: 15px;cursor: pointer;">
                <a href="/back-management/login.html" style="color: white;letter-spacing:1px;">登录管理端</a>
            </div>
        </div>

    </div>
</div>

<script>
    $('#username').bind('keydown', function (event) {
        var event = window.event || arguments.callee.caller.arguments[0];
        if (event.keyCode === 13) {
            var username = document.getElementById("username").value;
            var pwd = document.getElementById("pwd").value;
            if (username && pwd) {
                signin();
            }else {
                if (!username) {
                    document.getElementById('remind_div').style.visibility = 'visible';
                    document.getElementById('remind_text').innerText = '请输入用户名';
                    document.getElementById("username").focus();
                    return false
                }
                if (!pwd) {
                    document.getElementById('remind_div').style.visibility = 'visible';
                    document.getElementById('remind_text').innerText = '请输入密码';
                    document.getElementById("pwd").focus();
                    return false
                }
                document.getElementById('remind_div').style.visibility = 'hidden';
                signin();
            }
        }
    });

    $('#pwd').bind('keydown', function (event) {
        var event = window.event || arguments.callee.caller.arguments[0];
        if (event.keyCode === 13) {
            var username = document.getElementById("username").value;
            var pwd = document.getElementById("pwd").value;
            if (username && pwd) {
                signin();
            }else {
                if (!username) {
                    document.getElementById('remind_div').style.visibility = 'visible';
                    document.getElementById('remind_text').innerText = '请输入用户名';
                    document.getElementById("username").focus();
                    return false
                }
                if (!pwd) {
                    document.getElementById('remind_div').style.visibility = 'visible';
                    document.getElementById('remind_text').innerText = '请输入密码';
                    document.getElementById("pwd").focus();
                    return false
                }
                document.getElementById('remind_div').style.visibility = 'hidden';
                signin();
            }
        }
    });

    $('#submmit_but').bind('keydown', function (event) {
        var event = window.event || arguments.callee.caller.arguments[0];
        if (event.keyCode === 13) {
            var username = document.getElementById("username").value;
            var pwd = document.getElementById("pwd").value;
            if (username && pwd) {
                signin();
            }else {
                if (!username) {
                    document.getElementById('remind_div').style.visibility = 'visible';
                    document.getElementById('remind_text').innerText = '请输入用户名';
                    document.getElementById("username").focus();
                    return false
                }
                if (!pwd) {
                    document.getElementById('remind_div').style.visibility = 'visible';
                    document.getElementById('remind_text').innerText = '请输入密码';
                    document.getElementById("pwd").focus();
                    return false
                }
                document.getElementById('remind_div').style.visibility = 'hidden';
                signin();
            }
        }
    });

    function signin_but() {
        var username = document.getElementById("username").value;
        var pwd = document.getElementById("pwd").value;
        if (username && pwd) {
            signin();
        }else {
            if (!username) {
                document.getElementById('remind_div').style.visibility = 'visible';
                document.getElementById('remind_text').innerText = '请输入用户名';
                document.getElementById("username").focus();
                return false
            }else if (!pwd) {
                document.getElementById('remind_div').style.visibility = 'visible';
                document.getElementById('remind_text').innerText = '请输入密码';
                document.getElementById("pwd").focus();
                return false
            }else {
                document.getElementById('remind_div').style.visibility = 'hidden';
                signin();
            }
        }
    }

    function signin() {
    var form = new FormData();
    var username = document.getElementById("username").value;
    var pwd = document.getElementById("pwd").value;
    var remembered = document.getElementById("remembered").checked;
    // var remembered1 = document.getElementById("remembered").innerText;
    form.append("username", username);
    form.append("pwd", pwd);
    form.append("remembered", remembered);
    form.append("login_type", 'user');
    form.append("platform", 'web');

    var xhr = new XMLHttpRequest();
    var local_host = window.location.host;          // 获取当前IP
    xhr.open('post', "/personal-center/signin", true);
    xhr.send(form);
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
            if (xhr.status === 200) {
                var JsonData = JSON.parse(xhr.responseText);
                if(JsonData['code'] === 200){
                    if(JsonData['username'] === 'admin'){
                        location.href = "/system-setup/SuperSU_Pro.html";
                    }else {
                    location.href = "/personal-center/home.html";}
                }
                else{
                    alert(JsonData['message'])
            }

            }

        }
    };
}

</script>

</body>
</html>
